<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卖家-修改个人信息</title>
<link href="<?php echo $this->_webroot('/user/css/common.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->_webroot('/user/css/content1.css'); ?>" rel="stylesheet" type="text/css" />
<script src="<?php echo $this->_webroot('/user/js/jquery-1.7.1.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->_webroot('/user/js/common.js'); ?>" type="text/javascript"></script>


 
</head>
<body>
<psp:tags     htmlname='user_topnav1'  iconname='usertopnav1' />
<psp:tags     htmlname='user_topsearch'  iconname='usertopsearch' />

<div class="main">
	<div class="main-left">
    	<div class="title">会员管理中心</div>
        <psp:tags     htmlname='user_menulist'  iconname='usermenulist' />
    </div>
<link href="<?php echo $this->_webroot('/user/css/shoprequest.css'); ?>" rel="stylesheet" type="text/css" />   
    <div class="main-right main_right">
	
	<form action="<?php echo $this->_url('cart/cartdel/');?>" name="form" id="form1" method="get" onsubmit="return submitform();">
            <div class="cont">
				<div class="cont_title">
					<span class="tr_op">
					<a href="javascript:;" onclick="return go_to_buy()">现在结账</a><a href="/" target="_blank">继续购物</a>
					</span>
					我的购物车
				</div>            

				<table class="commodityCart" width="100%" border="0" cellspacing="0">
				  <tr>
					<th width="40"></th>
					<th width="150">商品图片</th>
					<th>商品信息</th>
					<th width="80">购买数量</th>
					<th width="130">操作</th>
				  </tr>
				  <?php if(!empty($result['data'])) {
					foreach($result['data'] as $k=> $v) {
					    foreach ($shoparray as $ke=>$va){
					    	if($v['shop_id']==$va){
					    		 unset($shoparray[$ke]);?>
					    	
					
    <tr class="shopInfo">
     	<td colspan="5">商家：<a href="<?php echo $v['shop_id'];?>" target="_blank" ><?php echo  $v['shop_name'];?></a></td>
     </tr>
     <?php }  }?>
				<tr class="commodity">
					<td align="center"><input type="checkbox" id="good_check" name="goods[]" onclick="add_buy(<?php echo $v['goods_id'];?>,<?php echo $v['shop_id'];?>,<?php echo $v['goods_number'];?>,this,this.checked)" value="<?php echo  $v['cart_id'];?>" /></td>
						<td align="center"><a href="<?php echo $this->_url('shop/productshow/'.$v['goods_id']);?>" target="_blank"><img src="<?php echo  $v['goods_thumb'];?>" width="80" height="80" onerror="this.src='<?php echo $this->_webroot('images1/nopic.gif'); ?>'"/></a></td>
					<!--	<input type="hidden" name="gid[]" value="<?php echo $v['goods_id'];?>" />-->
						<td class="name"><a href="<?php echo $this->_url('shop/productshow/'.$v['goods_id']);?>" target="_blank"><?php echo  $v['goods_name'];?></a>
						<br /> 商家：<a href="<?php echo $this->_url('shop/index/'.$v['shop_id']);?>" target="_blank"><?php echo  $v['shop_name'];?></a>
						<br />  价格：￥<span><?php echo  $v['goods_price'];?></span>元
						<br /> 添加日期：<?php echo  substr($v['add_time'],0,16);?> &nbsp;&nbsp;
						</td>
						<!--<input type="hidden" name="v[]" value="<?php //echo $v['goods_number']?>" />-->
						<td align="center" id="goodssortid_<?php echo  $v['cart_id'];?>">
							<span onclick="edit_sort(this,<?php echo  $v['cart_id'];?>)">&nbsp;<?php echo  $v['goods_number'];?>&nbsp;</span></td>
						<td align="center">
						<?php if($v['lock_flg']=='1') { ;?>
							<font color='red'>此商铺已经被锁定</font>
						<?php } else if($v['open_flg']=='1'){?>
							<font color='red'>此商铺已经被关闭</font>
						<?php } else {?>
							<input type="hidden" id="shop_id_<?php echo  $v['goods_id'];?>" value="<?php echo  $v['shop_id'];?>" />
							<a href="javascript:addFavorite(<?php echo  $v['goods_id'];?>);">收藏</a>
							<br />
							<a id="num_<?php echo  $v['cart_id'];?>" href="<?php echo $this->_url('user/buyorderadress/?');?>gid=<?php echo  $v['goods_id'];?>&v=<?php echo  $v['goods_number'];?>">购买</a>
						<?php }?><br />
						<a href="<?php echo $this->_url('cart/cartdel/?');?>id=<?php echo  $v['cart_id'];?><?php if($v['cart_id']==0){?>&goods_id=<?php echo $v['goods_id'];?><?php }?>" onclick="return confirm('确定要删除这商品在购物车吗？');">删除</a>
						</td>
					</tr>
				
					<?php }?>
						<?php if(!empty($row['sumvalue'])) {?>
							<tr><td colspan="5" style="border-bottom:0"><div>购物车价格总和为:<?php echo  $row['sumvalue'];?>元</div></td></tr>
						<?php }?>
                    <tr><td colspan="5" style="border-bottom:0">
			          <div class="page">
                            					  
					        <a class="upPage"  href="<?php echo $result['page']['prevPage']; ?>">上一页</a>
							<a  class="now"  href="<?php echo $result['page']['current']['url']; ?>" ><?php echo $result['page']['current']['num'] ; ?></a>
							<?php foreach($result['page']['plist'] as $k=> $v) { ?>
							<a  class="now"  href="<?php echo $v; ?>" ><?php echo $k ; ?></a>
							<?php } ?>
					        <a class="nextPage" href="<?php echo $result['page']['nextPage']; ?>" >下一页</a>
                     </div>		
					</td></tr>
					<!--<tr><th width="40"><input type="checkbox" onclick="checkall(this);" /></th><th align="left" colspan="4"><input class="submit" type="button" onclick="select_all()" value="全选"> <input class="submit" type="button" onclick="select_last()" value="反选"> <INPUT class="submit" type='submit' value='批量删除' name='deletesubmit'></th></tr>-->
					<?php  } else {?>
					<tr><th colspan="5" class="center">没有列表信息！</td></tr>
					<?php }?>
					<input type="hidden" name="app" value="user_order" />
					<input type="hidden" id="shop_user" value="<?php echo $user_id;?>" />
					<input type="hidden" name="iscart" value="1" />
				</table>
			  
			  
            </div>
	</form>	
	<form action="<?php echo $this->_url('user/buyorderadress/');?>" method="post" id="form2">
		<div id="gid_box"></div>
		<div id="shop_box"><input type="hidden" name="sid" id="sid" value="0" /></div>
		<div id="gnum_box"></div>
		<input type="hidden" name="app" value="user_order_adress" />
	</form>	

        

    </div>
    <div class="clear"></div>
</div>

<div class="footer">
    <psp:tags     htmlname='user_footer_helper'  iconname='userfooterhelper' />

</div>
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js');?>"></script>
<script>
	function addFavorite(id) {
			var shop_id = document.getElementById('shop_id_'+id).value;
			var user_id = document.getElementById('shop_user').value;
			if (shop_id == user_id){
				alert('自己的商品不能放入收藏');
			}else {
				ajax("<?php echo $this->_url('shop/goodsfavorite');?>","POST","id="+id,function(data){
					if(data == 1) {
						alert("已成功添加到您的收藏夹！");
					} else if(data == -1) {
						alert("此商品已在您的收藏夹里！");
					} else if(data == -2){
						alert("非法操作,产品不存在");							
					} else {
						alert("添加失败，请确认您是否已登陆！");
					}
				});
			}
		}
		
</script>
<script language="JavaScript">
<!--
function toggle_show(obj,id) {
	var re = /yes/i;
	var src = obj.src;
	var isshow = 1;
	var sss = src.search(re);
	if(sss > 0) {
		isshow = 0;
	}
	ajax("do.php?act=shop_isshow_toggle","POST","id="+id+"&s="+isshow,function(data){
		if(data) {
			obj.src = 'skin/default/images/'+data+'.gif';
		}
	});
}

var inputs = document.getElementsByTagName("input");
function submitform() {
	var status = document.getElementsByName("goods");
	var checknum = 0;
	for(var i=0; i<inputs.length; i++) {
		if(inputs[i].type=='checkbox') {
			if(inputs[i].checked) {
				checknum++;
			}
		}
	}
	if(checknum==0) {
		alert("致少要选择一项，才能进行操作！");
		return false;
	}else {
		var flg = confirm('本操作不可恢复，确认删除？');
		if (flg){
			return true;
		}
	}
	return false;
}

function checkall(obj) {
	if(obj.checked) {
		for(var i=0; i<inputs.length; i++) {
			if(inputs[i].type=='checkbox') {
				inputs[i].checked = true;
			}
		}
	} else {
		for(var i=0; i<inputs.length; i++) {
			if(inputs[i].type=='checkbox') {
				inputs[i].checked = false;
			}
		}
	}
}

var sort_value,number_value,price_value;
function edit_sort(span,id) {
	obj = document.getElementById("goodssortid_"+id);
	sort_value = span.innerHTML;
	sort_value = sort_value.replace(/&nbsp;/ig,"");
	obj.innerHTML = '<input style="width:35px" type="text" id="input_goodssortid_' + id + '" value="' + sort_value + '" onblur="edit_sort_post(this,' + id + ')"  maxlength="2" />';
	document.getElementById("input_goodssortid_"+id).focus();
}

function edit_sort_post(input,id) {
	var obj = document.getElementById("goodssortid_"+id);
	var num = document.getElementById("num_"+id);
	var re = /v=[0-9]+/g;
	if(isNaN(input.value)) {
		alert("请输入数字");
		obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + sort_value + '&nbsp;</span>';
		return ;
	}
	if(sort_value==input.value) {
		obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + sort_value + '&nbsp;</span>';
	} else {
		ajax("do.php?act=goods_num_edit","POST","id="+id+"&v="+input.value,function(data){
			if(data==1) {
				num.href = num.href.replace(re, "v="+input.value);
				obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + input.value + '&nbsp;</span>';
			} else {
				obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + sort_value + '&nbsp;</span>';
			}
		});
	}
}

function select_all() {
	for(var i=0; i<inputs.length; i++) {
		if(inputs[i].type=='checkbox') {
			inputs[i].checked = true;
		}
	}
}

function select_last() {
	for(var i=0; i<inputs.length; i++) {
		if(inputs[i].type=='checkbox') {
			if (inputs[i].checked == true){
				inputs[i].checked = false;
			}else if (inputs[i].checked == false){
				inputs[i].checked = true;
			}
		}
	}
}
function go_to_buy(){
	var obj = document.getElementById('form2');
	var gids = document.getElementsByName('gid[]');
	if(gids.length<=0){
		alert("请选择您要购买的商品");
	}else{
		obj.submit();
	}
	return false;
}
function add_buy(gid,shop_id,gnum,obj,bl){
	if(bl){
		if(document.getElementById("sid").value==0){
			document.getElementById("sid").value=shop_id;
		}
		if(document.getElementById('sid').value==shop_id){
			document.getElementById("gid_box").innerHTML+="<input type='hidden' name='gid[]'value='"+gid+"' />";
			document.getElementById("gnum_box").innerHTML+="<input type='hidden' name='v[]'value='"+gnum+"' />";
//			obj.checked=true;
		}else{
			alert("本商品不属于同一店铺！");
			obj.checked=false;
		}
	}else{
		var gids = document.getElementsByName('gid[]');
		var nums = document.getElementsByName("v[]");
		var temp_gid_box = "";
		var temp_gnum_box = "";
		for(i=0;i<gids.length;i++){
		    if(gid!=gids[i].value){
		        temp_gid_box+="<input type='hidden' name='gid[]' value='"+gids[i].value+"' />";
		        temp_gnum_box+="<input type='hidden' name='v[]' value='"+nums[i].value+"' />";
		    }
		}
		document.getElementById("gid_box").innerHTML=temp_gid_box;
		document.getElementById("gnum_box").innerHTML=temp_gnum_box;
		if(temp_gid_box.length<=0){
		    document.getElementById("sid").value=0;
		}
	}
}
//-->
</script>

</body>
</html>